home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / comms / other / amivnc / rfbproto.h < prev    next >
Text File  |  1999-06-14  |  22KB  |  681 lines

  1. //  Copyright (C) 1997, 1998 Olivetti & Oracle Research Laboratory
  2. //
  3. //  This file is part of the VNC system.
  4. //
  5. //  The VNC system is free software; you can redistribute it and/or modify
  6. //  it under the terms of the GNU General Public License as published by
  7. //  the Free Software Foundation; either version 2 of the License, or
  8. //  (at your option) any later version.
  9. //
  10. //  This program is distributed in the hope that it will be useful,
  11. //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. //  GNU General Public License for more details.
  14. //
  15. //  You should have received a copy of the GNU General Public License
  16. //  along with this program; if not, write to the Free Software
  17. //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  18. //  USA.
  19. //
  20. // If the source code for the VNC system is not available from the place 
  21. // whence you received this file, check http://www.orl.co.uk/vnc or contact
  22. // the authors on vnc@orl.co.uk for information on obtaining it.
  23.  
  24.  
  25. /*
  26.  * rfbproto.h - header file for the RFB protocol version 3.3
  27.  *
  28.  * Uses types CARD<n> for an n-bit unsigned integer, INT<n> for an n-bit signed
  29.  * integer (for n = 8, 16 and 32).
  30.  *
  31.  * All multiple byte integers are in big endian (network) order (most
  32.  * significant byte first).  Unless noted otherwise there is no special
  33.  * alignment of protocol structures.
  34.  *
  35.  *
  36.  * Once the initial handshaking is done, all messages start with a type byte,
  37.  * (usually) followed by message-specific data.  The order of definitions in
  38.  * this file is as follows:
  39.  *
  40.  *  (1) Structures used in several types of message.
  41.  *  (2) Structures used in the initial handshaking.
  42.  *  (3) Message types.
  43.  *  (4) Encoding types.
  44.  *  (5) For each message type, the form of the data following the type byte.
  45.  *      Sometimes this is defined by a single structure but the more complex
  46.  *      messages have to be explained by comments.
  47.  */
  48.  
  49.  
  50. /*****************************************************************************
  51.  *
  52.  * Structures used in several messages
  53.  *
  54.  *****************************************************************************/
  55.  
  56. /*-----------------------------------------------------------------------------
  57.  * Structure used to specify a rectangle.  This structure is a multiple of 4
  58.  * bytes so that it can be interspersed with 32-bit pixel data without
  59.  * affecting alignment.
  60.  */
  61.  
  62. #define CARD8 unsigned char
  63. #define CARD16 unsigned short
  64. #define CARD32 unsigned long
  65.  
  66. typedef struct {
  67.     CARD16 x;
  68.     CARD16 y;
  69.     CARD16 w;
  70.     CARD16 h;
  71. } rfbRectangle;
  72.  
  73. #define sz_rfbRectangle 8
  74.  
  75.  
  76. /*-----------------------------------------------------------------------------
  77.  * Structure used to specify pixel format.
  78.  */
  79.  
  80. typedef struct {
  81.  
  82.     CARD8 bitsPerPixel;        /* 8,16,32 only */
  83.  
  84.     CARD8 depth;        /* 8 to 32 */
  85.  
  86.     CARD8 bigEndian;        /* True if multi-byte pixels are interpreted
  87.                    as big endian, or if single-bit-per-pixel
  88.                    has most significant bit of the byte
  89.                    corresponding to first (leftmost) pixel. Of
  90.                    course this is meaningless for 8 bits/pix */
  91.  
  92.     CARD8 trueColour;        /* If false then we need a "colour map" to
  93.                    convert pixels to RGB.  If true, xxxMax and
  94.                    xxxShift specify bits used for red, green
  95.                    and blue */
  96.  
  97.     /* the following fields are only meaningful if trueColour is true */
  98.  
  99.     CARD16 redMax;        /* maximum red value (= 2^n - 1 where n is the
  100.                    number of bits used for red). Note this
  101.                    value is always in big endian order. */
  102.  
  103.     CARD16 greenMax;        /* similar for green */
  104.  
  105.     CARD16 blueMax;        /* and blue */
  106.  
  107.     CARD8 redShift;        /* number of shifts needed to get the red
  108.                    value in a pixel to the least significant
  109.                    bit. To find the red value from a given
  110.                    pixel, do the following:
  111.                    1) Swap pixel value according to bigEndian
  112.                       (e.g. if bigEndian is false and host byte
  113.                       order is big endian, then swap).
  114.                    2) Shift right by redShift.
  115.                    3) AND with redMax (in host byte order).
  116.                    4) You now have the red value between 0 and
  117.                       redMax. */
  118.  
  119.     CARD8 greenShift;        /* similar for green */
  120.  
  121.     CARD8 blueShift;        /* and blue */
  122.  
  123.     CARD8 pad1;
  124.     CARD16 pad2;
  125.  
  126. } rfbPixelFormat;
  127.  
  128. #define sz_rfbPixelFormat 16
  129.  
  130.  
  131.  
  132. /*****************************************************************************
  133.  *
  134.  * Initial handshaking messages
  135.  *
  136.  *****************************************************************************/
  137.  
  138. /*-----------------------------------------------------------------------------
  139.  * Protocol Version
  140.  *
  141.  * The server always sends 12 bytes to start which identifies the latest RFB
  142.  * protocol version number which it supports.  These bytes are interpreted
  143.  * as a string of 12 ASCII characters in the format "RFB xxx.yyy\n" where
  144.  * xxx and yyy are the major and minor version numbers (for version 3.3
  145.  * this is "RFB 003.003\n").
  146.  *
  147.  * The client then replies with a similar 12-byte message giving the version
  148.  * number of the protocol which should actually be used (which may be different
  149.  * to that quoted by the server).
  150.  *
  151.  * It is intended that both clients and servers may provide some level of
  152.  * backwards compatibility by this mechanism.  Servers in particular should
  153.  * attempt to provide backwards compatibility, and even forwards compatibility
  154.  * to some extent.  For example if a client demands version 3.1 of the
  155.  * protocol, a 3.0 server can probably assume that by ignoring requests for
  156.  * encoding types it doesn't understand, everything will still work OK.  This
  157.  * will probably not be the case for changes in the major version number.
  158.  *
  159.  * The format string below can be used in sprintf or sscanf to generate or
  160.  * decode the version string respectively.
  161.  */
  162.  
  163. #define rfbProtocolVersionFormat "RFB %03d.%03d\n"
  164. #define rfbProtocolMajorVersion 3
  165. #define rfbProtocolMinorVersion 3
  166.  
  167. typedef char rfbProtocolVersionMsg[13];    /* allow extra byte for null */
  168.  
  169. #define sz_rfbProtocolVersionMsg 12
  170.  
  171.  
  172. /*-----------------------------------------------------------------------------
  173.  * Authentication
  174.  *
  175.  * Once the protocol version has been decided, the server then sends a 32-bit
  176.  * word indicating whether any authentication is needed on the connection.
  177.  * The value of this word determines the authentication scheme in use.  For
  178.  * version 3.0 of the protocol this may have one of the following values:
  179.  */
  180.  
  181. #define rfbConnFailed 0
  182. #define rfbNoAuth 1
  183. #define rfbVncAuth 2
  184.  
  185. /*
  186.  * rfbConnFailed:    For some reason the connection failed (e.g. the server
  187.  *            cannot support the desired protocol version).  This is
  188.  *            followed by a string describing the reason (where a
  189.  *            string is specified as a 32-bit length followed by that
  190.  *            many ASCII characters).
  191.  *
  192.  * rfbNoAuth:        No authentication is needed.
  193.  *
  194.  * rfbVncAuth:        The VNC authentication scheme is to be used.  A 16-byte
  195.  *            challenge follows, which the client encrypts as
  196.  *            appropriate using the password and sends the resulting
  197.  *            16-byte response.  If the response is correct, the
  198.  *            server sends the 32-bit word rfbVncAuthOK.  If a simple
  199.  *            failure happens, the server sends rfbVncAuthFailed and
  200.  *            closes the connection. If the server decides that too
  201.  *            many failures have occurred, it sends rfbVncAuthTooMany
  202.  *            and closes the connection.  In the latter case, the
  203.  *            server should not allow an immediate reconnection by
  204.  *            the client.
  205.  */
  206.  
  207. #define rfbVncAuthOK 0
  208. #define rfbVncAuthFailed 1
  209. #define rfbVncAuthTooMany 2
  210.  
  211.  
  212. /*-----------------------------------------------------------------------------
  213.  * Client Initialisation Message
  214.  *
  215.  * Once the client and server are sure that they're happy to talk to one
  216.  * another, the client sends an initialisation message.  At present this
  217.  * message only consists of a boolean indicating whether the server should try
  218.  * to share the desktop by leaving other clients connected, or give exclusive
  219.  * access to this client by disconnecting all other clients.
  220.  */
  221.  
  222. typedef struct {
  223.     CARD8 shared;
  224. } rfbClientInitMsg;
  225.  
  226. #define sz_rfbClientInitMsg 1
  227.  
  228.  
  229. /*-----------------------------------------------------------------------------
  230.  * Server Initialisation Message
  231.  *
  232.  * After the client initialisation message, the server sends one of its own.
  233.  * This tells the client the width and height of the server's framebuffer,
  234.  * its pixel format and the name associated with the desktop.
  235.  */
  236.  
  237. typedef struct {
  238.     CARD16 framebufferWidth;
  239.     CARD16 framebufferHeight;
  240.     rfbPixelFormat format;    /* the server's preferred pixel format */
  241.     CARD32 nameLength;
  242.     /* followed by char name[nameLength] */
  243. } rfbServerInitMsg;
  244.  
  245. #define sz_rfbServerInitMsg (8 + sz_rfbPixelFormat)
  246.  
  247.  
  248. /*
  249.  * Following the server initialisation message it's up to the client to send
  250.  * whichever protocol messages it wants.  Typically it will send a
  251.  * SetPixelFormat message and a SetEncodings message, followed by a
  252.  * FramebufferUpdateRequest.  From then on the server will send
  253.  * FramebufferUpdate messages in response to the client's
  254.  * FramebufferUpdateRequest messages.  The client should send
  255.  * FramebufferUpdateRequest messages with incremental set to true when it has
  256.  * finished processing one FramebufferUpdate and is ready to process another.
  257.  * With a fast client, the rate at which FramebufferUpdateRequests are sent
  258.  * should be regulated to avoid hogging the network.
  259.  */
  260.  
  261.  
  262.  
  263. /*****************************************************************************
  264.  *
  265.  * Message types
  266.  *
  267.  *****************************************************************************/
  268.  
  269. /* server -> client */
  270.  
  271. #define rfbFramebufferUpdate 0
  272. #define rfbSetColourMapEntries 1
  273. #define rfbBell 2
  274. #define rfbServerCutText 3
  275.  
  276.  
  277. /* client -> server */
  278.  
  279. #define rfbSetPixelFormat 0
  280. #define rfbFixColourMapEntries 1    /* not currently supported */
  281. #define rfbSetEncodings 2
  282. #define rfbFramebufferUpdateRequest 3
  283. #define rfbKeyEvent 4
  284. #define rfbPointerEvent 5
  285. #define rfbClientCutText 6
  286.  
  287.  
  288.  
  289.  
  290. /*****************************************************************************
  291.  *
  292.  * Encoding types
  293.  *
  294.  *****************************************************************************/
  295.  
  296. #define rfbEncodingRaw 0
  297. #define rfbEncodingCopyRect 1
  298. #define rfbEncodingRRE 2
  299. #define rfbEncodingCoRRE 4
  300. #define rfbEncodingHextile 5
  301.  
  302.  
  303.  
  304. /*****************************************************************************
  305.  *
  306.  * Server -> client message definitions
  307.  *
  308.  *****************************************************************************/
  309.  
  310.  
  311. /*-----------------------------------------------------------------------------
  312.  * FramebufferUpdate - a block of rectangles to be copied to the framebuffer.
  313.  *
  314.  * This message consists of a header giving the number of rectangles of pixel
  315.  * data followed by the rectangles themselves.  The header is padded so that
  316.  * together with the type byte it is an exact multiple of 4 bytes (to help
  317.  * with alignment of 32-bit pixels):
  318.  */
  319.  
  320. typedef struct {
  321.     CARD8 type;            /* always rfbFramebufferUpdate */
  322.     CARD8 pad;
  323.     CARD16 nRects;
  324.     /* followed by nRects rectangles */
  325. } rfbFramebufferUpdateMsg;
  326.  
  327. #define sz_rfbFramebufferUpdateMsg 4
  328.  
  329. /*
  330.  * Each rectangle of pixel data consists of a header describing the position
  331.  * and size of the rectangle and a type word describing the encoding of the
  332.  * pixel data, followed finally by the pixel data.  Note that if the client has
  333.  * not sent a SetEncodings message then it will only receive raw pixel data.
  334.  * Also note again that this structure is a multiple of 4 bytes.
  335.  */
  336.  
  337. typedef struct {
  338.     rfbRectangle r;
  339.     CARD32 encoding;    /* one of the encoding types rfbEncoding... */
  340. } rfbFramebufferUpdateRectHeader;
  341.  
  342. #define sz_rfbFramebufferUpdateRectHeader (sz_rfbRectangle + 4)
  343.  
  344.  
  345. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  346.  * Raw Encoding.  Pixels are sent in top-to-bottom scanline order,
  347.  * left-to-right within a scanline with no padding in between.
  348.  */
  349.  
  350.  
  351. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  352.  * CopyRect Encoding.  The pixels are specified simply by the x and y position
  353.  * of the source rectangle.
  354.  */
  355.  
  356. typedef struct {
  357.     CARD16 srcX;
  358.     CARD16 srcY;
  359. } rfbCopyRect;
  360.  
  361. #define sz_rfbCopyRect 4
  362.  
  363.  
  364. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  365.  * RRE - Rise-and-Run-length Encoding.  We have an rfbRREHeader structure
  366.  * giving the number of subrectangles following.  Finally the data follows in
  367.  * the form [<bgpixel><subrect><subrect>...] where each <subrect> is
  368.  * [<pixel><rfbRectangle>].
  369.  */
  370.  
  371. typedef struct {
  372.     CARD32 nSubrects;
  373. } rfbRREHeader;
  374.  
  375. #define sz_rfbRREHeader 4
  376.  
  377.  
  378. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  379.  * CoRRE - Compact RRE Encoding.  We have an rfbRREHeader structure giving
  380.  * the number of subrectangles following.  Finally the data follows in the form
  381.  * [<bgpixel><subrect><subrect>...] where each <subrect> is
  382.  * [<pixel><rfbCoRRERectangle>].  This means that
  383.  * the whole rectangle must be at most 255x255 pixels.
  384.  */
  385.  
  386. typedef struct {
  387.     CARD8 x;
  388.     CARD8 y;
  389.     CARD8 w;
  390.     CARD8 h;
  391. } rfbCoRRERectangle;
  392.  
  393. #define sz_rfbCoRRERectangle 4
  394.  
  395.  
  396. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  397.  * Hextile Encoding.  The rectangle is divided up into "tiles" of 16x16 pixels,
  398.  * starting at the top left going in left-to-right, top-to-bottom order.  If
  399.  * the width of the rectangle is not an exact multiple of 16 then the width of
  400.  * the last tile in each row will be correspondingly smaller.  Similarly if the
  401.  * height is not an exact multiple of 16 then the height of each tile in the
  402.  * final row will also be smaller.  Each tile begins with a "subencoding" type
  403.  * byte, which is a mask made up of a number of bits.  If the Raw bit is set
  404.  * then the other bits are irrelevant; w*h pixel values follow (where w and h
  405.  * are the width and height of the tile).  Otherwise the tile is encoded in a
  406.  * similar way to RRE, except that the position and size of each subrectangle
  407.  * can be specified in just two bytes.  The other bits in the mask are as
  408.  * follows:
  409.  *
  410.  * BackgroundSpecified - if set, a pixel value follows which specifies
  411.  *    the background colour for this tile.  The first non-raw tile in a
  412.  *    rectangle must have this bit set.  If this bit isn't set then the
  413.  *    background is the same as the last tile.
  414.  *
  415.  * ForegroundSpecified - if set, a pixel value follows which specifies
  416.  *    the foreground colour to be used for all subrectangles in this tile.
  417.  *    If this bit is set then the SubrectsColoured bit must be zero.
  418.  *
  419.  * AnySubrects - if set, a single byte follows giving the number of
  420.  *    subrectangles following.  If not set, there are no subrectangles (i.e.
  421.  *    the whole tile is just solid background colour).
  422.  *
  423.  * SubrectsColoured - if set then each subrectangle is preceded by a pixel
  424.  *    value giving the colour of that subrectangle.  If not set, all
  425.  *    subrectangles are the same colour, the foreground colour;  if the
  426.  *    ForegroundSpecified bit wasn't set then the foreground is the same as
  427.  *    the last tile.
  428.  *
  429.  * The position and size of each subrectangle is specified in two bytes.  The
  430.  * Pack macros below can be used to generate the two bytes from x, y, w, h,
  431.  * and the Extract macros can be used to extract the x, y, w, h values from
  432.  * the two bytes.
  433.  */
  434.  
  435. #define rfbHextileRaw            (1 << 0)
  436. #define rfbHextileBackgroundSpecified    (1 << 1)
  437. #define rfbHextileForegroundSpecified    (1 << 2)
  438. #define rfbHextileAnySubrects        (1 << 3)
  439. #define rfbHextileSubrectsColoured    (1 << 4)
  440.  
  441. #define rfbHextilePackXY(x,y) (((x) << 4) | (y))
  442. #define rfbHextilePackWH(w,h) ((((w)-1) << 4) | ((h)-1))
  443. #define rfbHextileExtractX(byte) ((byte) >> 4)
  444. #define rfbHextileExtractY(byte) ((byte) & 0xf)
  445. #define rfbHextileExtractW(byte) (((byte) >> 4) + 1)
  446. #define rfbHextileExtractH(byte) (((byte) & 0xf) + 1)
  447.  
  448.  
  449. /*-----------------------------------------------------------------------------
  450.  * SetColourMapEntries - these messages are only sent if the pixel
  451.  * format uses a "colour map" (i.e. trueColour false) and the client has not
  452.  * fixed the entire colour map using FixColourMapEntries.  In addition they
  453.  * will only start being sent after the client has sent its first
  454.  * FramebufferUpdateRequest.  So if the client always tells the server to use
  455.  * trueColour then it never needs to process this type of message.
  456.  */
  457.  
  458. typedef struct {
  459.     CARD8 type;            /* always rfbSetColourMapEntries */
  460.     CARD8 pad;
  461.     CARD16 firstColour;
  462.     CARD16 nColours;
  463.  
  464.     /* Followed by nColours * 3 * CARD16
  465.        r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */
  466.  
  467. } rfbSetColourMapEntriesMsg;
  468.  
  469. #define sz_rfbSetColourMapEntriesMsg 6
  470.  
  471.  
  472.  
  473. /*-----------------------------------------------------------------------------
  474.  * Bell - ring a bell on the client if it has one.
  475.  */
  476.  
  477. typedef struct {
  478.     CARD8 type;            /* always rfbBell */
  479. } rfbBellMsg;
  480.  
  481. #define sz_rfbBellMsg 1
  482.  
  483.  
  484.  
  485. /*-----------------------------------------------------------------------------
  486.  * ServerCutText - the server has new text in its cut buffer.
  487.  */
  488.  
  489. typedef struct {
  490.     CARD8 type;            /* always rfbServerCutText */
  491.     CARD8 pad1;
  492.     CARD16 pad2;
  493.     CARD32 length;
  494.     /* followed by char text[length] */
  495. } rfbServerCutTextMsg;
  496.  
  497. #define sz_rfbServerCutTextMsg 8
  498.  
  499.  
  500. /*-----------------------------------------------------------------------------
  501.  * Union of all server->client messages.
  502.  */
  503.  
  504. typedef union {
  505.     CARD8 type;
  506.     rfbFramebufferUpdateMsg fu;
  507.     rfbSetColourMapEntriesMsg scme;
  508.     rfbBellMsg b;
  509.     rfbServerCutTextMsg sct;
  510. } rfbServerToClientMsg;
  511.  
  512.  
  513.  
  514. /*****************************************************************************
  515.  *
  516.  * Message definitions (client -> server)
  517.  *
  518.  *****************************************************************************/
  519.  
  520.  
  521. /*-----------------------------------------------------------------------------
  522.  * SetPixelFormat - tell the RFB server the format in which the client wants
  523.  * pixels sent.
  524.  */
  525.  
  526. typedef struct {
  527.     CARD8 type;            /* always rfbSetPixelFormat */
  528.     CARD8 pad1;
  529.     CARD16 pad2;
  530.     rfbPixelFormat format;
  531. } rfbSetPixelFormatMsg;
  532.  
  533. #define sz_rfbSetPixelFormatMsg (sz_rfbPixelFormat + 4)
  534.  
  535.  
  536. /*-----------------------------------------------------------------------------
  537.  * FixColourMapEntries - when the pixel format uses a "colour map", fix
  538.  * read-only colour map entries.
  539.  *
  540.  *    ***************** NOT CURRENTLY SUPPORTED *****************
  541.  */
  542.  
  543. typedef struct {
  544.     CARD8 type;            /* always rfbFixColourMapEntries */
  545.     CARD8 pad;
  546.     CARD16 firstColour;
  547.     CARD16 nColours;
  548.  
  549.     /* Followed by nColours * 3 * CARD16
  550.        r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */
  551.  
  552. } rfbFixColourMapEntriesMsg;
  553.  
  554. #define sz_rfbFixColourMapEntriesMsg 6
  555.  
  556.  
  557. /*-----------------------------------------------------------------------------
  558.  * SetEncodings - tell the RFB server which encoding types we accept.  Put them
  559.  * in order of preference, if we have any.  We may always receive raw
  560.  * encoding, even if we don't specify it here.
  561.  */
  562.  
  563. typedef struct {
  564.     CARD8 type;            /* always rfbSetEncodings */
  565.     CARD8 pad;
  566.     CARD16 nEncodings;
  567.     /* followed by nEncodings * CARD32 encoding types */
  568. } rfbSetEncodingsMsg;
  569.  
  570. #define sz_rfbSetEncodingsMsg 4
  571.  
  572.  
  573. /*-----------------------------------------------------------------------------
  574.  * FramebufferUpdateRequest - request for a framebuffer update.  If incremental
  575.  * is true then the client just wants the changes since the last update.  If
  576.  * false then it wants the whole of the specified rectangle.
  577.  */
  578.  
  579. typedef struct {
  580.     CARD8 type;            /* always rfbFramebufferUpdateRequest */
  581.     CARD8 incremental;
  582.     CARD16 x;
  583.     CARD16 y;
  584.     CARD16 w;
  585.     CARD16 h;
  586. } rfbFramebufferUpdateRequestMsg;
  587.  
  588. #define sz_rfbFramebufferUpdateRequestMsg 10
  589.  
  590.  
  591. /*-----------------------------------------------------------------------------
  592.  * KeyEvent - key press or release
  593.  *
  594.  * Keys are specified using the "keysym" values defined by the X Window System.
  595.  * For most ordinary keys, the keysym is the same as the corresponding ASCII
  596.  * value.  Other common keys are:
  597.  *
  598.  * BackSpace        0xff08
  599.  * Tab            0xff09
  600.  * Return or Enter    0xff0d
  601.  * Escape        0xff1b
  602.  * Insert        0xff63
  603.  * Delete        0xffff
  604.  * Home            0xff50
  605.  * End            0xff57
  606.  * Page Up        0xff55
  607.  * Page Down        0xff56
  608.  * Left            0xff51
  609.  * Up            0xff52
  610.  * Right        0xff53
  611.  * Down            0xff54
  612.  * F1            0xffbe
  613.  * F2            0xffbf
  614.  * ...            ...
  615.  * F12            0xffc9
  616.  * Shift        0xffe1
  617.  * Control        0xffe3
  618.  * Meta            0xffe7
  619.  * Alt            0xffe9
  620.  */
  621.  
  622. typedef struct {
  623.     CARD8 type;            /* always rfbKeyEvent */
  624.     CARD8 down;            /* true if down (press), false if up */
  625.     CARD16 pad;
  626.     CARD32 key;            /* key is specified as an X keysym */
  627. } rfbKeyEventMsg;
  628.  
  629. #define sz_rfbKeyEventMsg 8
  630.  
  631.  
  632. /*-----------------------------------------------------------------------------
  633.  * PointerEvent - mouse/pen move and/or button press.
  634.  */
  635.  
  636. typedef struct {
  637.     CARD8 type;            /* always rfbPointerEvent */
  638.     CARD8 buttonMask;        /* bits 0-7 are buttons 1-8, 0=up, 1=down */
  639.     CARD16 x;
  640.     CARD16 y;
  641. } rfbPointerEventMsg;
  642.  
  643. #define rfbButton1Mask 1
  644. #define rfbButton2Mask 2
  645. #define rfbButton3Mask 4
  646.  
  647. #define sz_rfbPointerEventMsg 6
  648.  
  649.  
  650.  
  651. /*-----------------------------------------------------------------------------
  652.  * ClientCutText - the client has new text in its cut buffer.
  653.  */
  654.  
  655. typedef struct {
  656.     CARD8 type;            /* always rfbClientCutText */
  657.     CARD8 pad1;
  658.     CARD16 pad2;
  659.     CARD32 length;
  660.     /* followed by char text[length] */
  661. } rfbClientCutTextMsg;
  662.  
  663. #define sz_rfbClientCutTextMsg 8
  664.  
  665.  
  666.  
  667. /*-----------------------------------------------------------------------------
  668.  * Union of all client->server messages.
  669.  */
  670.  
  671. typedef union {
  672.     CARD8 type;
  673.     rfbSetPixelFormatMsg spf;
  674.     rfbFixColourMapEntriesMsg fcme;
  675.     rfbSetEncodingsMsg se;
  676.     rfbFramebufferUpdateRequestMsg fur;
  677.     rfbKeyEventMsg ke;
  678.     rfbPointerEventMsg pe;
  679.     rfbClientCutTextMsg cct;
  680. } rfbClientToServerMsg;
  681.